var app = getApp();
const Zan = require('../../dist/index');
var Const = require('./../../utils/const.js');

Page(Object.assign({}, Zan.TopTips, {

	data: {
		isLogin: false
	},

	onLoad: function (options) {
		var that = this;
		app.battery.testLogin().then(function (r) {
			if (!r) {
				that.setData({
					isLogin: false
				});
			} else {
				that.setData({
					isLogin: true
				});
			}
		});
	},

	onReady: function () {

	},

	onShow: function () {

	},

	onHide: function () {

	},

	logout: function () {
		var that = this;

		app.battery.common('logout', {ticket: app.data.token}).then(function (res) {
			app.data.token = null;
			app.data.member = null;
			//app.data.member.id = null;
			//app.data.member.name = null;
			//app.data.member.mobile = null;
			app.wechat.setStorage(Const.DATA.KEY_TOKEN, null);
			wx.navigateBack({
				delta: 1
			})
		}).catch(function (err) {
			console.error(err.message);
		});
	}
}));